package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_role")
@ApiModel(value = "Role", parent = Base.class, description = "角色")
public class Role extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = -6606374735387684030L;

    @ApiModelProperty(value = "角色名称")
    @Column(length = 255)
    private String name;

    @ApiModelProperty(value = "角色别名")
    @Column(length = 255)
    private String dame;

    @ApiModelProperty(value = "角色下的用户")
    @JsonIgnore
    @ManyToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "roles")
    @Fetch(FetchMode.SUBSELECT)
    private Set<User> users = new HashSet<User>(0);

}
